home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing;
-
- import com.sun.java.swing.event.CellEditorListener;
- import com.sun.java.swing.event.ChangeEvent;
- import com.sun.java.swing.event.EventListenerList;
- import com.sun.java.swing.table.TableCellEditor;
- import com.sun.java.swing.tree.TreeCellEditor;
- import java.awt.Component;
- import java.awt.event.MouseEvent;
- import java.io.Serializable;
- import java.util.EventObject;
-
- public class DefaultCellEditor implements TableCellEditor, TreeCellEditor, Serializable {
- protected EventListenerList listenerList = new EventListenerList();
- protected transient ChangeEvent changeEvent = null;
- protected JComponent editorComponent;
- protected EditorDelegate delegate;
- protected int clickCountToStart = 1;
- static Class class$com$sun$java$swing$event$CellEditorListener;
-
- public DefaultCellEditor(JCheckBox x) {
- this.editorComponent = x;
- this.delegate = new 1(this);
- ((JCheckBox)this.editorComponent).addActionListener(this.delegate);
- }
-
- public DefaultCellEditor(JComboBox x) {
- this.editorComponent = x;
- this.delegate = new 2(this);
- ((JComboBox)this.editorComponent).addItemListener(this.delegate);
- }
-
- public DefaultCellEditor(JTextField x) {
- this.editorComponent = x;
- this.clickCountToStart = 2;
- this.delegate = new 3(this);
- ((JTextField)this.editorComponent).addActionListener(this.delegate);
- }
-
- public void addCellEditorListener(CellEditorListener l) {
- EventListenerList var10000 = this.listenerList;
- Class var10001 = class$com$sun$java$swing$event$CellEditorListener;
- if (var10001 == null) {
- try {
- var10001 = Class.forName("com.sun.java.swing.event.CellEditorListener");
- } catch (ClassNotFoundException var2) {
- throw new NoClassDefFoundError(((Throwable)var2).getMessage());
- }
-
- class$com$sun$java$swing$event$CellEditorListener = var10001;
- }
-
- var10000.add(var10001, l);
- }
-
- public void cancelCellEditing() {
- this.delegate.cancelCellEditing();
- this.fireEditingCanceled();
- }
-
- protected void fireEditingCanceled() {
- Object[] listeners = this.listenerList.getListenerList();
-
- for(int i = listeners.length - 2; i >= 0; i -= 2) {
- Object var10000 = listeners[i];
- Class var10001 = class$com$sun$java$swing$event$CellEditorListener;
- if (var10001 == null) {
- try {
- var10001 = Class.forName("com.sun.java.swing.event.CellEditorListener");
- } catch (ClassNotFoundException var3) {
- throw new NoClassDefFoundError(((Throwable)var3).getMessage());
- }
-
- class$com$sun$java$swing$event$CellEditorListener = var10001;
- }
-
- if (var10000 == var10001) {
- if (this.changeEvent == null) {
- this.changeEvent = new ChangeEvent(this);
- }
-
- ((CellEditorListener)listeners[i + 1]).editingCanceled(this.changeEvent);
- }
- }
-
- }
-
- protected void fireEditingStopped() {
- Object[] listeners = this.listenerList.getListenerList();
-
- for(int i = listeners.length - 2; i >= 0; i -= 2) {
- Object var10000 = listeners[i];
- Class var10001 = class$com$sun$java$swing$event$CellEditorListener;
- if (var10001 == null) {
- try {
- var10001 = Class.forName("com.sun.java.swing.event.CellEditorListener");
- } catch (ClassNotFoundException var3) {
- throw new NoClassDefFoundError(((Throwable)var3).getMessage());
- }
-
- class$com$sun$java$swing$event$CellEditorListener = var10001;
- }
-
- if (var10000 == var10001) {
- if (this.changeEvent == null) {
- this.changeEvent = new ChangeEvent(this);
- }
-
- ((CellEditorListener)listeners[i + 1]).editingStopped(this.changeEvent);
- }
- }
-
- }
-
- public Object getCellEditorValue() {
- return this.delegate.getCellEditorValue();
- }
-
- public int getClickCountToStart() {
- return this.clickCountToStart;
- }
-
- public Component getComponent() {
- return this.editorComponent;
- }
-
- public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
- this.delegate.setValue(value);
- return this.editorComponent;
- }
-
- public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) {
- String stringValue = tree.convertValueToText(value, isSelected, expanded, leaf, row, false);
- this.delegate.setValue(stringValue);
- return this.editorComponent;
- }
-
- public boolean isCellEditable(EventObject anEvent) {
- return anEvent instanceof MouseEvent && ((MouseEvent)anEvent).getClickCount() < this.clickCountToStart ? false : this.delegate.isCellEditable(anEvent);
- }
-
- public void removeCellEditorListener(CellEditorListener l) {
- EventListenerList var10000 = this.listenerList;
- Class var10001 = class$com$sun$java$swing$event$CellEditorListener;
- if (var10001 == null) {
- try {
- var10001 = Class.forName("com.sun.java.swing.event.CellEditorListener");
- } catch (ClassNotFoundException var2) {
- throw new NoClassDefFoundError(((Throwable)var2).getMessage());
- }
-
- class$com$sun$java$swing$event$CellEditorListener = var10001;
- }
-
- var10000.remove(var10001, l);
- }
-
- public void setClickCountToStart(int count) {
- this.clickCountToStart = count;
- }
-
- public boolean shouldSelectCell(EventObject anEvent) {
- boolean retValue = true;
- if (this.isCellEditable(anEvent) && (anEvent == null || ((MouseEvent)anEvent).getClickCount() >= this.clickCountToStart)) {
- retValue = this.delegate.startCellEditing(anEvent);
- }
-
- return retValue;
- }
-
- public boolean stopCellEditing() {
- boolean stopped = this.delegate.stopCellEditing();
- if (stopped) {
- this.fireEditingStopped();
- }
-
- return stopped;
- }
- }
-